# -*- coding: utf-8 -*-
# @Time    : 2022/4/18 16:20
# @File : login_page.py
# @Author  : Yang
from web_keys.key_word import KeyWords
from page_elements.login_page import *
import allure


class Login(KeyWords):
    # 打开网页
    def open_browser(self, url):
        self.open_url(url)

    # 输入用户名
    def input_username(self, username):
        self.locator_list(username_input_box).send_keys(username)

    # 输入密码
    def input_password(self, password):
        self.locator_list(password_input_box).send_keys(password)

    # 点击登录按钮
    def click_login_button(self):
        self.locator_list(login_button).click()

    # 登录
    def login_(self, url, userinfo):
        with allure.step('01.打开登录页'):
            self.open_browser(url)
        with allure.step('02.等待5秒'):
            self.wait_time(3)
        with allure.step('03.输入用户名'):
            self.input_username(userinfo['username'])
        with allure.step('04.输入密码'):
            self.input_password(userinfo['password'])
        with allure.step('05.点击登录按钮'):
            self.click_login_button()


